package com.lxmes.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lxmes.common.annotation.Log;
import com.lxmes.common.core.controller.BaseController;
import com.lxmes.common.core.domain.AjaxResult;
import com.lxmes.common.enums.BusinessType;
import com.lxmes.business.domain.NcNoticeBill;
import com.lxmes.business.service.INcNoticeBillService;
import com.lxmes.common.utils.poi.ExcelUtil;
import com.lxmes.common.core.page.TableDataInfo;

/**
 * 开票通知单Controller
 * 
 * @author zhangzhiyu
 * @date 2022-11-29
 */
@RestController
@RequestMapping("/business/bill")
public class NcNoticeBillController extends BaseController
{
    @Autowired
    private INcNoticeBillService ncNoticeBillService;

    /**
     * 查询开票通知单列表
     */
    @PreAuthorize("@ss.hasPermi('business:bill:list')")
    @GetMapping("/list")
    public TableDataInfo list(NcNoticeBill ncNoticeBill)
    {
        startPage();
        List<NcNoticeBill> list = ncNoticeBillService.selectNcNoticeBillList(ncNoticeBill);
        return getDataTable(list);
    }

    /**
     * 导出开票通知单列表
     */
    @PreAuthorize("@ss.hasPermi('business:bill:export')")
    @Log(title = "开票通知单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NcNoticeBill ncNoticeBill)
    {
        List<NcNoticeBill> list = ncNoticeBillService.selectNcNoticeBillList(ncNoticeBill);
        ExcelUtil<NcNoticeBill> util = new ExcelUtil<NcNoticeBill>(NcNoticeBill.class);
        util.exportExcel(response, list, "开票通知单数据");
    }

    /**
     * 获取开票通知单详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:bill:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ncNoticeBillService.selectNcNoticeBillById(id));
    }

    /**
     * 新增开票通知单
     */
    @PreAuthorize("@ss.hasPermi('business:bill:add')")
    @Log(title = "开票通知单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NcNoticeBill ncNoticeBill)
    {
        return toAjax(ncNoticeBillService.insertNcNoticeBill(ncNoticeBill));
    }

    /**
     * 修改开票通知单
     */
    @PreAuthorize("@ss.hasPermi('business:bill:edit')")
    @Log(title = "开票通知单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NcNoticeBill ncNoticeBill)
    {
        return toAjax(ncNoticeBillService.updateNcNoticeBill(ncNoticeBill));
    }

    /**
     * 删除开票通知单
     */
    @PreAuthorize("@ss.hasPermi('business:bill:remove')")
    @Log(title = "开票通知单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ncNoticeBillService.deleteNcNoticeBillByIds(ids));
    }
    /* 入库结算生成开票通知单*/
    @Log(title = "入库结算生成开票通知单", businessType = BusinessType.INSERT)
    @PostMapping("/rukuJieSuanAddBill")
    public AjaxResult rukuJieSuanAddBill(@RequestBody NcNoticeBill ncNoticeBill)
    {
        return toAjax(ncNoticeBillService.rukuJieSuanAddBill(ncNoticeBill));
    }
    /* 出库结算生成开票通知单*/
    @Log(title = "出库结算生成开票通知单", businessType = BusinessType.INSERT)
    @PostMapping("/chukuJieSuanAddBill")
    public AjaxResult chukuJieSuanAddBill(@RequestBody NcNoticeBill ncNoticeBill)
    {
        return toAjax(ncNoticeBillService.chukuJieSuanAddBill(ncNoticeBill));
    }
}
